package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.HaDrugdict;
import com.ruoyi.system.service.IHaDrugdictService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 药品列表Controller
 * 
 * @author 鲍小伟
 * @date 2025-11-19
 */
@RestController
@RequestMapping("/system/drugdict")
public class HaDrugdictController extends BaseController
{
    @Autowired
    private IHaDrugdictService haDrugdictService;

    /**
     * 查询药品列表列表
     */
    @PreAuthorize("@ss.hasPermi('system:drugdict:list')")
    @GetMapping("/list")
    public TableDataInfo list(HaDrugdict haDrugdict)
    {
        startPage();
        List<HaDrugdict> list = haDrugdictService.selectHaDrugdictList(haDrugdict);
        return getDataTable(list);
    }

    /**
     * 导出药品列表列表
     */
    @PreAuthorize("@ss.hasPermi('system:drugdict:export')")
    @Log(title = "药品列表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HaDrugdict haDrugdict)
    {
        List<HaDrugdict> list = haDrugdictService.selectHaDrugdictList(haDrugdict);
        ExcelUtil<HaDrugdict> util = new ExcelUtil<HaDrugdict>(HaDrugdict.class);
        util.exportExcel(response, list, "药品列表数据");
    }

    /**
     * 获取药品列表详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:drugdict:query')")
    @GetMapping(value = "/{drugid}")
    public AjaxResult getInfo(@PathVariable("drugid") Integer drugid)
    {
        return success(haDrugdictService.selectHaDrugdictByDrugid(drugid));
    }

    /**
     * 新增药品列表
     */
    @PreAuthorize("@ss.hasPermi('system:drugdict:add')")
    @Log(title = "药品列表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HaDrugdict haDrugdict)
    {
        return toAjax(haDrugdictService.insertHaDrugdict(haDrugdict));
    }

    /**
     * 修改药品列表
     */
    @PreAuthorize("@ss.hasPermi('system:drugdict:edit')")
    @Log(title = "药品列表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HaDrugdict haDrugdict)
    {
        return toAjax(haDrugdictService.updateHaDrugdict(haDrugdict));
    }

    /**
     * 删除药品列表
     */
    @PreAuthorize("@ss.hasPermi('system:drugdict:remove')")
    @Log(title = "药品列表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{drugids}")
    public AjaxResult remove(@PathVariable Integer[] drugids)
    {
        return toAjax(haDrugdictService.deleteHaDrugdictByDrugids(drugids));
    }
}
